import { getBaseCategoryList } from '@/api';
import { reqGetListRecommend } from "@/api";
import { reqGetFloorList } from "@/api";
const actions = {
    //请求列表数据
    async getCategoryList(context) {
        let categoryList = await getBaseCategoryList()
        //当请求码为200时,交给mutations处理
        if (categoryList.code == '200') {
            //数据太长删掉最后一个
            categoryList.data.pop()
            categoryList.data.pop()
            context.commit('GETCATEGORYLIST', categoryList.data)
        }
    },
    //请求轮播图数据
    async getListRecommend(context) {
        let listRecommend = await reqGetListRecommend()
        if (listRecommend.code == '200') {
            context.commit("GETLISTRECOMMED", listRecommend.data)
        }

    },
    //请求floor数据
    async getFloorList(context) {
        let result = await reqGetFloorList()
        if (result.code == '200') {
            context.commit("GETFLOORLIST", result.data)
        }

    },

}
const mutations = {
    GETCATEGORYLIST(state, value) {
        state.categoryList = value
    },
    GETLISTRECOMMED(state, value) {
        state.listRecommend = value
    },
    GETFLOORLIST(state, floorList) {
        state.floorList = floorList
    }
}
const state = {
    categoryList: [],
    listRecommend: [],
    floorList: []
}
const getters = {}
export default {
    namespaced: true,// 开启命名空间
    actions, mutations, state, getters
}
